package Sort;

import java.util.Random;

public class Test {

    public static int[] creatArr() {
        Random random = new Random();
        int[] arr = new int[100000];
        for (int i = 0; i < 100000; i++) {
            arr[i] = random.nextInt(100000);
        }
        return arr;
    }

    public static void heapSortTest(int[] arr) {
        long begin = System.currentTimeMillis();
        HeapSort heapSort = new HeapSort();
        heapSort.operation(arr);
        long end = System.currentTimeMillis();
        System.out.println("堆排序所需时间: " + (end - begin));
    }

    public static void InsertionSort(int[] arr) {
        long begin = System.currentTimeMillis();
        InsertionSort insertionSort = new InsertionSort();

        insertionSort.operation(arr);
        long end = System.currentTimeMillis();
        System.out.println("插入排序所需时间: " + (end - begin));
    }

    public static void ShellSortTest(int[] arr) {
        long begin = System.currentTimeMillis();
        ShellSort shellSort = new ShellSort();

        shellSort.operation(arr);
        long end = System.currentTimeMillis();
        System.out.println("希尔排序所需时间: " + (end - begin));
    }

    public static void main(String[] args) {
        int[] arr = Test.creatArr();

        Test.heapSortTest(arr);
        Test.ShellSortTest(arr);
        Test.InsertionSort(arr);
    }
}
